<!DOCTYPE html>

<html lang='en'>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/react.development16.4.0.js"></script>
    <script src="./lib/react-dom.development16.4.0.js"></script>
    <script src="./lib/babel.min.js"></script>
    <style>
    .current{
        color: red;
    }
    </style>
</head>

<body>
    <div id="app">
    </div>
    <script type="text/babel">
        class MyComponent extends React.Component{
            constructor(props){
            super(props);
            this.state = {
                list:[1,2,3,4],
                current:1
            };
            }
            handleClick(item){
            this.setState({
                current: item,
            });
            alert(item);
            }
            render(){
            return(
                <ul>
                {this.state.list.map(
                    (item,index) => (
                    <li key={index} className={this.state.current === item ? 'current':''}
                        onClick={this.handleClick.bind(this,item)}>
                        {item}
                    </li>
                    )
                )}
                </ul>
            );
            }
        }
    ReactDOM.render(
    <MyComponent/>,
    document.getElementById('app')
    );
    </script>
</body>

</html>